/*
 * SplasPlanel.java
 *
 * Created on 24 de noviembre de 2006, 06:31 PM
 */

package splas;

import splas.*;
import java.io.File;
import javax.swing.JOptionPane;
import util.LoadProperties;

/**
 *
 * @author  jsanchez
 */
public class SplasPlanel extends javax.swing.JPanel {
    String image=null;
    boolean isIcon=false;
    /** Creates new form SplasPlanel */
    public SplasPlanel() {
        try {
            image=LoadProperties.getProperties("conf.properties","image").trim();
            String app=LoadProperties.getProperties("conf.properties","run").trim();
            initComponents();
            if(!new File(image).exists())
                this.jLabel1.setText(" Cargando "+app.trim()+" ");
            else{
                isIcon=true;
                jLabel1.setIcon(new javax.swing.ImageIcon(image));            
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null,"No se pudo cargar la imagen\n"+e.toString());
        }                
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Progreso = new javax.swing.JProgressBar();
        jLabel1 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(51, 51, 51));

        jLabel1.setBackground(new java.awt.Color(204, 255, 204));
        jLabel1.setFont(new java.awt.Font("Dialog", 0, 10));
        jLabel1.setOpaque(true);
        jLabel1.setPreferredSize(new java.awt.Dimension(100, 100));

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
            .add(Progreso, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 52, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Progreso, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents
    
    public void setValorMaxino(Integer valor){
        this.Progreso.setMaximum(valor);
    }
    
    public void setValor(Integer valor,String lib){
        if(!isIcon)
            this.jLabel1.setText(" Cargando "+lib.trim()+" ");
        this.Progreso.setValue(valor);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JProgressBar Progreso;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
    
}
